package com.aheizi.oa.service.impl;

import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.aheizi.oa.base.DaoSupportImpl;
import com.aheizi.oa.domain.User;
import com.aheizi.oa.service.UserService;

@Service
@Transactional 
public class UserServiceImpl extends DaoSupportImpl<User> implements UserService {

	public User findByLoginUsernameAndPassword(String loginName, String password) {

		//使用密码的MD5摘要进行对比
		String md5Digest = DigestUtils.md5Hex(password);
		
		System.out.println(loginName+password+"   "+ md5Digest);
		
		return (User) getSession().createQuery(
				"FROM User u where u.loginName=? and u.password=?")
				.setParameter(0, loginName)
				.setParameter(1, md5Digest)
				.uniqueResult();
	}

}
